{% extends "master.jinja2" %}
{% block main %}
<div class="container">
    <div class="row">
        <div class="panel panel-primary">
            <div class="panel-heading center-block">我的订单</div>
            <div class="panel-body" id="shoping_cart_body">
                {% if orders %}
                <table class="table" id="shoping_cart_table">
                    <tr>
                         <td>订单号</td>
                         <td>下单时间</td>
                         <td>商品</td>
                         <td>总金额</td>
                         <td>操作</td>
                    </tr>
                    {% for order in orders %}
                    {% if order.items %}
                    <tr id="shoping_tr_{{order.id}}">
                        <td>{{order.id}}</td>
                        <td>{{order.add_time}}</td>
                        <td>
                            <ul class="list-group">
                                {% set total_price=0 %}
                                {% for item in order.items %}
                                    <li class="list-group-item">
                                    <a href="{{request.route_url('Item',id=item.id)}}">
                                    <img src="{{request.static_url('myproject:static/uploads/20160801/20160801175305728.jpg')}}">{{item.name}}</a></li>
                                {% set total_price=total_price+item.price %}
                                {% endfor %}
                                </ul>
                           </td>
                        <td><span class="total" id="shoping_total_{{order.id}}">{{ total_price}}</span>元</td>
                        <td><a href="javascript:void(0)" class="delete_shoping" data-id="{{order.id}}">取消订单</a></td>
                    </tr>
                    {% endif %}
                    {% endfor %}
                </table>
                <div class="clearfix"></div>
                {% else %}
                <h2 class="text-center text-info">订单为空，<a href="{{request.route_url('home')}}">请继续购物</a></h2>
                 {% endif %}
            </div>
        </div>
    </div>
</div>
{% endblock %}